module.exports = app => {

    app.once('server', async server => {
        console.log("KuJoMiva 服务器已启动")
        try {
            const mysqlUnmcc = await app.fetch()
            app.database = app.mysql.createInstance(mysqlUnmcc)
            const mysqlWuye = await app.fetchWuye()
            app.databaseWuye = app.mysql.createInstance(mysqlWuye)
        }catch (err) {
            console.log(err)
        }
    })

    app.on('error', (err, ctx) => {
        console.log("发生了错误")
    })

    app.on('request', ctx => {
        console.log("接收到了请求")
        // ctx.body = {}
        // ctx.status = 200
        ctx.set('Access-Control-Allow-Origin', '*');
    })

    app.on('response', ctx => {
        const used = Date.now() - ctx.starttime
        console.log(used, "ms内响应了请求")
    })

}


